import { createRouter, createWebHistory } from 'vue-router';
import AdminLayout from '@/components/layouts/AdminLayout.vue';
import Home from '@/views/HomeView.vue';
import Login from '@/views/login.vue';
import Menu from '@/views/menu.vue';
import Role from '@/views/role.vue';
import Group from '@/views/group.vue';
import Permission from '@/views/permission.vue';
import Callback from '@/views/callback.vue'; // 直接引入 Callback 组件
import usergroup from '@/views/usergroup.vue';

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      component: AdminLayout,
    },
    {
      path: '/user',
      component: AdminLayout,
      children: [
        { path: '', component: Home } // 根据需要调整
      ]
    },
    {
      path: '/login',
      component: Login
    },
    {
      path: '/menu',
      component: AdminLayout,
      children: [
        { path: '', component: Menu }
      ]
    },
    {
      path: '/group',
      component: AdminLayout,
      children: [
        { path: '', component: Group }
      ]
    },
    {
      path: '/permission',
      component: AdminLayout,
      children: [
        { path: '', component: Permission }
      ]
    },
    {
      path: '/user/:id(\\d+)/group',
      component: AdminLayout, // 直接指定 AdminLayout
      children: [
        { path: '', component: usergroup } // 直接渲染 Group 组件
      ]
    },
    {
      path: '/role',
      name: "userlist",
      component: AdminLayout,
      children: [
        { path: '', component: Role }
      ]
    },
    {
      path: '/login/callback',
      name: 'Callback',
      component: Callback // 直接指定 Callback 组件
    },
  ]
})

export default router
